import { Router, type Router as ExpressRouter } from 'express';
import {
  register,
  login,
  refreshToken,
  getCurrentUser,
  changePassword,
  logout
} from '@/controllers/authController';
import { authenticateToken } from '@/middleware/auth';
import { validateRegister, validateLogin, validateChangePassword } from '@/middleware/validation';

const router: ExpressRouter = Router();

// 公开路由（不需要认证）
router.post('/register', validateRegister, register);
router.post('/login', validateLogin, login);
router.post('/refresh-token', refreshToken);

// 受保护路由（需要认证）
router.get('/me', authenticateToken, getCurrentUser);
router.post('/change-password', authenticateToken, validateChangePassword, changePassword);
router.post('/logout', authenticateToken, logout);

export default router;